@@ -33,7 +33,6 @@ import androidx.test.uiautomator.Until
33
33
import androidx.test.uiautomator.Until.findObject
34
34
import mozilla.components.browser.state.state.searchEngines
35
35
import org.hamcrest.CoreMatchers.allOf
36
- import org.hamcrest.CoreMatchers.containsString
37
36
import org.hamcrest.CoreMatchers.instanceOf
38
37
import org.hamcrest.CoreMatchers.not
39
38
import org.hamcrest.Matchers
@@ -141,7 +140,11 @@ class HomeScreenRobot {
141
140
fun verifyRecentBookmarksSectionIsDisplayed () = assertRecentBookmarksSectionIsDisplayed()
142
141
fun verifyRecentBookmarksSectionIsNotDisplayed () = assertRecentBookmarksSectionIsNotDisplayed()
143
142
144
- fun verifyRecentlyVisitedSearchGroupDisplayed (shouldBeDisplayed : Boolean , searchTerm : String , groupSize : Int ) {
143
+ fun verifyRecentlyVisitedSearchGroupDisplayed (
144
+ shouldBeDisplayed : Boolean ,
145
+ searchTerm : String ,
146
+ groupSize : Int
147
+ ) {
145
148
// checks if the search group exists in the Recently visited section
146
149
if (shouldBeDisplayed) {
147
150
recentlyVisitedList.waitForExists(waitingTime)
@@ -162,7 +165,11 @@ class HomeScreenRobot {
162
165
}
163
166
}
164
167
165
- fun verifyCurrentSearchGroupIsDisplayed (shouldBeDisplayed : Boolean , searchTerm : String , groupSize : Int = 0) {
168
+ fun verifyCurrentSearchGroupIsDisplayed (
169
+ shouldBeDisplayed : Boolean ,
170
+ searchTerm : String ,
171
+ groupSize : Int = 0
172
+ ) {
166
173
// checks search group in the Jump back in section
167
174
if (shouldBeDisplayed) {
168
175
assertTrue(
@@ -392,7 +399,10 @@ class HomeScreenRobot {
392
399
return TabDrawerRobot .Transition ()
393
400
}
394
401
395
- fun expandCollection (title : String , interact : CollectionRobot .() -> Unit ): CollectionRobot .Transition {
402
+ fun expandCollection (
403
+ title : String ,
404
+ interact : CollectionRobot .() -> Unit
405
+ ): CollectionRobot .Transition {
396
406
// Depending on the screen dimensions collections might report as visible on screen
397
407
// but actually have the bottom toolbar above so interactions with collections might fail.
398
408
// As a quick solution we'll try scrolling to the element below collection on the homescreen
@@ -405,8 +415,12 @@ class HomeScreenRobot {
405
415
return CollectionRobot .Transition ()
406
416
}
407
417
408
- fun openRecentlyVisitedSearchGroupHistoryList (title : String , interact : HistoryRobot .() -> Unit ): HistoryRobot .Transition {
409
- val searchGroup = recentlyVisitedList.getChildByText(UiSelector ().text(title), title, true )
418
+ fun openRecentlyVisitedSearchGroupHistoryList (
419
+ title : String ,
420
+ interact : HistoryRobot .() -> Unit
421
+ ): HistoryRobot .Transition {
422
+ val searchGroup =
423
+ recentlyVisitedList.getChildByText(UiSelector ().text(title), title, true )
410
424
searchGroup.waitForExists(waitingTimeShort)
411
425
searchGroup.click()
412
426
@@ -438,7 +452,8 @@ private fun assertKeyboardVisibility(isExpectedToBeVisible: Boolean) =
438
452
.contains(" mInputShown=true" )
439
453
)
440
454
441
- private fun navigationToolbar () = mDevice.findObject(UiSelector ().resourceId(" $packageName :id/toolbar" ))
455
+ private fun navigationToolbar () =
456
+ mDevice.findObject(UiSelector ().resourceId(" $packageName :id/toolbar" ))
442
457
443
458
private fun assertNavigationToolbar () = assertTrue(navigationToolbar().waitForExists(waitingTime))
444
459
@@ -447,7 +462,8 @@ private fun assertFocusedNavigationToolbar() =
447
462
.check(matches(withEffectiveVisibility(Visibility .VISIBLE )))
448
463
449
464
private fun assertHomeScreen () {
450
- mDevice.findObject(UiSelector ().resourceId(" $packageName :id/homeLayout" )).waitForExists(waitingTime)
465
+ mDevice.findObject(UiSelector ().resourceId(" $packageName :id/homeLayout" ))
466
+ .waitForExists(waitingTime)
451
467
onView(ViewMatchers .withResourceName(" homeLayout" ))
452
468
.check(matches(withEffectiveVisibility(Visibility .VISIBLE )))
453
469
}
@@ -471,18 +487,23 @@ private fun assertTabButton() =
471
487
.check(matches(withEffectiveVisibility(Visibility .VISIBLE )))
472
488
473
489
private fun assertCollectionsHeader () =
474
- onView(allOf(withText(" Collections" )))
475
- .check(matches(withEffectiveVisibility(Visibility .VISIBLE )))
490
+ assertTrue(
491
+ mDevice.findObject(
492
+ UiSelector ().textContains(
493
+ " Collections"
494
+ )
495
+ ).waitForExists(waitingTime)
496
+ )
476
497
477
498
private fun assertNoCollectionsText () =
478
- onView (
479
- withText (
480
- containsString (
499
+ assertTrue (
500
+ mDevice.findObject (
501
+ UiSelector ().textContains (
481
502
" Collect the things that matter to you.\n " +
482
503
" Group together similar searches, sites, and tabs for quick access later."
483
504
)
484
- )
485
- ).check(matches(isDisplayed()))
505
+ ).waitForExists(waitingTime)
506
+ )
486
507
487
508
private fun assertHomeComponent () =
488
509
onView(ViewMatchers .withResourceName(" sessionControlRecyclerView" ))
@@ -521,6 +542,7 @@ private fun assertStartSyncHeader() {
521
542
onView(allOf(withText(R .string.onboarding_account_sign_in_header_1)))
522
543
.check(matches(withEffectiveVisibility(Visibility .VISIBLE )))
523
544
}
545
+
524
546
private fun assertAccountsSignInButton () =
525
547
onView(ViewMatchers .withResourceName(" fxa_sign_in_button" ))
526
548
.check(matches(withEffectiveVisibility(Visibility .VISIBLE )))
@@ -530,6 +552,7 @@ private fun assertChooseThemeHeader() {
530
552
onView(withText(" Choose your theme" ))
531
553
.check(matches(withEffectiveVisibility(Visibility .VISIBLE )))
532
554
}
555
+
533
556
private fun assertChooseThemeText () {
534
557
scrollToElementByText(" Choose your theme" )
535
558
onView(allOf(withText(" Save some battery and your eyesight with dark mode." )))
@@ -559,6 +582,7 @@ private fun assertDarkThemeDescription() {
559
582
onView(allOf(withText(" Dark theme" )))
560
583
.check(matches(withEffectiveVisibility(Visibility .VISIBLE )))
561
584
}
585
+
562
586
private fun assertAutomaticThemeToggle () {
563
587
scrollToElementByText(" Choose your theme" )
564
588
onView(withId(R .id.theme_automatic_radio_button))
@@ -686,9 +710,11 @@ private fun assertTopSiteContextMenuItems() {
686
710
)
687
711
}
688
712
689
- private fun assertJumpBackInSectionIsDisplayed () = assertTrue(jumpBackInSection().waitForExists(waitingTime))
713
+ private fun assertJumpBackInSectionIsDisplayed () =
714
+ assertTrue(jumpBackInSection().waitForExists(waitingTime))
690
715
691
- private fun assertJumpBackInSectionIsNotDisplayed () = assertFalse(jumpBackInSection().waitForExists(waitingTimeShort))
716
+ private fun assertJumpBackInSectionIsNotDisplayed () =
717
+ assertFalse(jumpBackInSection().waitForExists(waitingTimeShort))
692
718
693
719
private fun assertRecentBookmarksSectionIsDisplayed () =
694
720
assertTrue(recentBookmarksSection().waitForExists(waitingTime))
@@ -698,7 +724,8 @@ private fun assertRecentBookmarksSectionIsNotDisplayed() =
698
724
699
725
private fun privateBrowsingButton () = onView(withId(R .id.privateBrowsingButton))
700
726
701
- private fun saveTabsToCollectionButton () = onView(withId(R .id.add_tabs_to_collections_button))
727
+ private fun saveTabsToCollectionButton () =
728
+ mDevice.findObject(UiSelector ().textContains(getStringResource(R .string.tabs_menu_save_to_collection1)))
702
729
703
730
private fun tabsCounter () = onView(withId(R .id.tab_button))
704
731
@@ -709,7 +736,8 @@ private fun recentBookmarksSection() =
709
736
mDevice.findObject(UiSelector ().textContains(getStringResource(R .string.recent_bookmarks_title)))
710
737
711
738
private fun startBrowsingButton (): UiObject {
712
- val startBrowsingButton = mDevice.findObject(UiSelector ().resourceId(" $packageName :id/finish_button" ))
739
+ val startBrowsingButton =
740
+ mDevice.findObject(UiSelector ().resourceId(" $packageName :id/finish_button" ))
713
741
homeScreenList()
714
742
.scrollIntoView(startBrowsingButton)
715
743
homeScreenList()
0 commit comments